#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from PySide import QtGui, QtCore
import random
import math
import time
#from PySide.QtGui import QGraphicsItem

__author__ = 'akamoroz'

class Square(QtGui.QGraphicsItem):

    colour = 1
    def __init__(self):
        QtGui.QGraphicsItem.__init__(self)
        #self.color=colorh


    def boundingRect(self):
        return QtCore.QRectF(0, 0, 64, 64)

    def paint(self, painter, option, widget):
        #gradient = QtGui.QRadialGradient()
        if self.colour == 0:
            c = QtGui.QColor(name='black')
        else:
            c = QtGui.QColor(0,0, 0,0)
        #c = QtGui.QColor(255,0, 0,0)
        #gradient.setColorAt(0, c)
        #gradient.setColorAt(0, c)
        #painter.setBrush(QtGui.QBrush(gradient))
        painter.setBrush(c)
        painter.setPen(QtGui.QColor(name='black'))
        #painter.setPen(QtGui.QPen(QtCore.Qt.black, 2))
        painter.drawRect(0, 0, 64, 64)
        #QtGui.QGraphicsSimpleTextItem(text='A')

class Letter(Square):
    def paint(self, painter, option, widget):
        painter.set

    

class Window(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle(u"Morozov Chess")

        #игровое поле
        self.scene = QtGui.QGraphicsScene()
        self.scene.setSceneRect(0, 0, 640, 640)

        # виджет игрового поля
        gamearea = QtGui.QGraphicsView(self.scene)
        gamearea.setRenderHint(QtGui.QPainter.Antialiasing)

        grid = QtGui.QVBoxLayout()
        grid.addWidget(gamearea)

        self.setLayout(grid)

def new_square(scene):
    letter = ((0,''),(1,'A'),(2,'B'),(3,'C'),(4,'D'),(5,'E'),(6,'F'),(7,'G'),(8,'H'),(9,''))
    for i in range(10):
        '''
        sqr = QtGui.QGraphicsRectItem()
        sqr2 = QtGui.QGraphicsRectItem()
        sqr.setRect(i*64,0,64,64)
        sqr2.setRect(i*64,640-64,64,64)
        '''
        lbl = QtGui.QGraphicsTextItem()
        lbl.setPlainText(letter[i][1])
        lbl.setPos(15+i*64,7)
        lbl.setScale(2.5)
        lbl3 = QtGui.QGraphicsTextItem()
        lbl3.setPlainText(str(i) if i not in (0,9) else '')
        lbl3.setPos(15,i*64)
        lbl3.setScale(2.5)
        lbl4 = QtGui.QGraphicsTextItem()
        lbl4.setPlainText(str(i) if i not in (0,9) else '')
        lbl4.setPos(640-64+15,i*64)
        lbl4.setScale(2.5)
        lbl2 = QtGui.QGraphicsTextItem()
        lbl2.setPlainText(letter[i][1])
        lbl2.setPos(15+i*64,640-64+7)
        lbl2.setScale(2.5)
        #scene.addItem(sqr)
        #scene.addItem(sqr2)
        scene.addItem(lbl)
        scene.addItem(lbl2)
        scene.addItem(lbl3)
        scene.addItem(lbl4)

    for i in range(8):
        for j in range(8):
            x = j * 64+64
            y = i * 64+64
            newS = Square()
            newS.colour = 0 if (i+j)%2==0 else 1
            scene.addItem(newS)
            newS.setPos(x, y)



app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
new_square(window.scene)
sys.exit(app.exec_())
